#include <GL/gl.h>
#include <GL/glu.h>
#include <SDL/SDL.h>
#include "Game.h"
#include "Constants.h"
#include <iostream>

int main(int, char*[])
{
	std::cout << "initialising SDL and OpenGL...\n";
	//Init SDL with best video mode
	SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
	const SDL_VideoInfo* info = SDL_GetVideoInfo();
	int vidFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER;
	if (info->hw_available)
	{
		vidFlags |= SDL_HWSURFACE;
	}
	else
	{
		vidFlags |= SDL_SWSURFACE;
	}
	int bpp = info->vfmt->BitsPerPixel;
	SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, bpp, vidFlags);
	//gl setup
	glEnable(GL_TEXTURE_2D);
	glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
	
	glMatrixMode(GL_PROJECTION);
//	glMatrixMode(GL_MODELVIEW);
	glEnable(GL_DEPTH_TEST);
	gluPerspective(45, (float)WINDOW_WIDTH / WINDOW_HEIGHT, 0.1, 100);
	glMatrixMode(GL_MODELVIEW);
	
	Game game;
	std::cout << "running!\n";
	game.run();
	return 0;
}
